// import wx from 'weixin-js-sdk';

// import { copy } from '@/application/utils/copy';

// import { commonApi } from '../apis/home';
// import { ActivityInfo } from './../../types/apiType';
// import { isWeChat } from './common';
// // 微信appid
// const APPID = 'wx7d5b6d66775f5f74';
// import { Toast } from '@nutui/nutui-react';
interface ShareParams {
  content: string;
  imgUrl?: string;
  title: string;
  url: string;
  success: (res: any) => void;
  fail: (res: any) => void;
  complete: (res: any) => void;
}

import { globalValue } from '@/application/context/global';
export const share = async (config: Partial<ShareParams>) => {
  const url = `${window.location.origin}/invitee/${globalValue?.spreadKey}?goodsId=${globalValue?.goodInfo?.id}&activityId=${globalValue?.activityInfo?.id}`;

  console.log('share url', url);

  // copy(url);
  // Toast.show({ title: '我是测试分享的，分享链接已复制剪贴板', lockScroll: true });
  const cfg = {
    shareTitle: config.title, //分享标题
    shareContent: config.complete, //分享文案描述
    shareWebpageUrl: decodeURIComponent(url || ''), //分享后点击访问的地址
    //0 微信 1 微信朋友圈 2 微博 3 QQ 4 空间 按照这个送
    actions: [
      {
        shareType: '0',
        shareTitle: '微信'
      },
      {
        shareType: '1',
        shareTitle: '微信朋友圈'
      }
    ],
    callback: (data: any) => {
      console.log('微信分享data:' + data);
    }
  };
  $Fw.MSCWebPluginAliActionSheetShare(cfg);
};
